package edu.biwu.cookie02;/**
 * @author 王俊彪
 * @version 1.0
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/path01/setCookie02")
public class SetCookie02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Cookie cookie = new Cookie("gender", "male1");
//        Cookie cookie = new Cookie("name", "张三");
        cookie.setPath("/day07_cookie_session");
        cookie.setMaxAge(30);//设置最大存活时间为30秒
        response.setContentType("text/html;charset=utf-8");
        response.addCookie(cookie);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
